import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';

import 'my_app_bar.dart';
import 'my_scroll_view.dart';

class MyScaffold extends StatelessWidget {
  final PreferredSizeWidget? appBar;
  final Color? backgroundColor;
  final Widget? body;
  final List<Widget>? children;
  final EdgeInsetsGeometry? padding;
  final String title;
  final Widget? bottomButton;
  final CrossAxisAlignment crossAxisAlignment;
  final KeyboardActionsConfig? keyboardConfig;
  final Widget? floatingActionButton;
  final ScrollController? controller;
  final Widget? endDrawer;

  const MyScaffold({
    Key? key,
    this.appBar,
    this.backgroundColor,
    this.title = "",
    this.children,
    this.padding,
    this.body,
    this.bottomButton,
    this.crossAxisAlignment = CrossAxisAlignment.start,
    this.keyboardConfig,
    this.floatingActionButton,
    this.controller,
    this.endDrawer,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: appBar ?? MyPageAppBar(title: title),
      backgroundColor: backgroundColor,
      endDrawer: endDrawer,
      body: SafeArea(
        child: body ??
            MyScrollView(
              padding: padding,
              bottomButton: bottomButton,
              crossAxisAlignment: crossAxisAlignment,
              keyboardConfig: keyboardConfig,
              controller: controller,
              children: children ?? [],
            ),
      ),
      floatingActionButton: floatingActionButton,
    );
  }
}
